﻿<%@ Page Language="C#" MasterPageFile="~/WebSite/manager.Master" AutoEventWireup="true" CodeFile="m_data_HeightWeight.aspx.cs" Inherits="WebSite_m_data_HeightWeight" Title="无标题页" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <style type="text/css">
        .InfoStyle
        {
        	margin:25px;
        	margin-left:0px;
        	width:620px;
        	overflow:visible;
       	}
       	.InfoStyle h1
       	{
       		font-size:20px;
       		background-image:url(../images/Clip.png);
       		background-repeat:no-repeat;
       		width:300px;
       		margin:-23px auto auto 180px;
       		padding-top:15px;
       		padding-left:50px;
       		height:40px;
       	}
       	.InsertBtnStyle
       	{
       		margin:5px 200px auto;
    	    width:90px;
    	    height:30px;
    	    background-color:#669DF0;
    	    font-size:16px;
    	    font-weight:bold;
    	    color:#FFFFFF;
       	}
       	.TableStyle
       	{
       		margin:0px 50px;
       	}
    </style>
    
<div class="InfoStyle">
        <h1>身高体重比信息表</h1>
        <br />
        <div class="TableStyle">
        <asp:GridView ID="UserDetailGridView" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False"  DataKeyNames="LowHeight,LowWeight,Sex"
            DataSourceID="SqlDataSource1" CellPadding="4" Font-Size="14px" 
                                        PageSize="20" ForeColor="#333333" GridLines="None">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="LowHeight" HeaderText="身高下限" SortExpression="LowHeight">
                </asp:BoundField>
                <asp:BoundField DataField="HighHeight" HeaderText="身高上限" SortExpression="HighHeight">
                </asp:BoundField>
                <asp:BoundField DataField="LowWeight" HeaderText="体重下限" SortExpression="LowWeight">
                </asp:BoundField>
                <asp:BoundField DataField="HighWeight" HeaderText="体重上限" SortExpression="HighWeight" >
                </asp:BoundField>
                <asp:TemplateField HeaderText="性别" SortExpression="Sex">
                    <ItemTemplate>
                        <asp:DropDownList runat="server" ID="SexDropDownList" 
                            SelectedValue='<%# Bind("Sex", "{0}") %>'>
                            <asp:ListItem Value="False">男</asp:ListItem>
                            <asp:ListItem Value="True">女</asp:ListItem>
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Level" HeaderText="等级"  SortExpression="Level"  ControlStyle-Width="80px">
                </asp:BoundField>
                <asp:BoundField DataField="Mark" HeaderText="对应分数" SortExpression="Mark" >
                </asp:BoundField>
            </Columns>
            <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <br />
        <table style="font-size:15px; text-align:center; margin-left:30px;">
            <tr>
                <td>身高下限</td>
                <td>身高上限</td>
                <td>体重下限</td>
                <td>体重上限</td>
                <td>性别</td>
                <td>等级</td>
                <td>分数</td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="HeightLowTextBox" runat="server" style="width:50px;"
                        EnableViewState="False" Wrap="False" Width="59px"/>
                </td>
                <td>
                    <asp:TextBox ID="HeightHighTextBox" runat="server" style="width:50px;" 
                        EnableViewState="False" Wrap="False" Width="59px"/>
                </td>
                <td>
                    <asp:TextBox ID="WeightLowTextBox" runat="server" style="width:50px;" 
                        EnableViewState="False" Wrap="False"/>
                </td>
                <td>
                    <asp:TextBox ID="WeightHighTextBox" runat="server" style="width:50px" />
                </td>
                <td>
                    <asp:DropDownList ID="SexDropDownList" runat="server">
                        <asp:ListItem Value="0">男</asp:ListItem>
                        <asp:ListItem Value="1">女</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td>
                    <asp:TextBox ID="LevelTextBox" runat="server" style="width:70px" MaxLength="5"/>
                </td>
                <td>
                    <asp:TextBox ID="MarkTextBox" runat="server" style="width:50px" Height="19px" 
                        Width="83px" />
                </td>
           </tr>
        </table>
        <asp:Button ID="InsertBtn" runat="server" Text="插入信息" OnClick="InsertBtn_Click" 
                CssClass="InsertBtnStyle"/>
    </div>
        <asp:RangeValidator ID="RangeValidator1" runat="server" 
            ControlToValidate="HeightLowTextBox" Display="Dynamic" 
            ErrorMessage="身高下限范围为0-260CM之间" MaximumValue="260" MinimumValue="0" 
            SetFocusOnError="True" Type="Double">身高范围为0-260CM之间</asp:RangeValidator>
        <asp:RangeValidator ID="RangeValidator2" runat="server" 
            ControlToValidate="HeightHighTextBox" Display="Dynamic" 
            ErrorMessage="身高上限范围为0-260CM之间" MaximumValue="260" MinimumValue="0" 
            SetFocusOnError="True" Type="Double">身高范围为0-260CM之间</asp:RangeValidator>
        <asp:CompareValidator ID="CompareValidator1" runat="server" 
            ErrorMessage="身高上限要大于身高下限" ControlToCompare="HeightLowTextBox" 
            ControlToValidate="HeightHighTextBox" Display="Dynamic" Type="Double" 
            Operator="GreaterThan"></asp:CompareValidator>
            <asp:RangeValidator ID="RangeValidator3" runat="server" 
            ControlToValidate="WeightLowTextBox" Display="Dynamic" 
            ErrorMessage="体重下限范围为0-200KG之间" MaximumValue="200" MinimumValue="0" 
            SetFocusOnError="True" Type="Double">体重范围为0-200KG之间</asp:RangeValidator>
        <asp:RangeValidator ID="RangeValidator4" runat="server" 
            ControlToValidate="WeightLowTextBox" Display="Dynamic" 
            ErrorMessage="体重上限范围为0-200CM之间" MaximumValue="200" MinimumValue="0" 
            SetFocusOnError="True" Type="Double">体重范围为0-200KG之间</asp:RangeValidator>
        <asp:CompareValidator ID="CompareValidator2" runat="server" 
            ErrorMessage="体重上限要大于体重下限" ControlToCompare="WeightLowTextBox" 
            ControlToValidate="WeightHighTextBox" Display="Dynamic" Type="Double" 
            Operator="GreaterThan"></asp:CompareValidator>
        <asp:RangeValidator ID="RangeValidator5" runat="server" 
            ControlToValidate="MarkTextBox" Display="Dynamic" 
            ErrorMessage="分数范围在0-100之间" MaximumValue="100" MinimumValue="0" 
            SetFocusOnError="True" Type="Integer">分数范围在0-100之间</asp:RangeValidator>
            
  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
            
        SelectCommand="SELECT [LowHeight], [HighHeight], [LowWeight], [HighWeight], [Sex], [Mark], [Level] FROM [HeightWeightLevelTable]" 
        DeleteCommand="DELETE FROM [HeightWeightLevelTable] WHERE [LowHeight] = @original_LowHeight AND [LowWeight] = @original_LowWeight AND [Sex] = @original_Sex AND [HighHeight] = @original_HighHeight AND [HighWeight] = @original_HighWeight AND [Mark] = @original_Mark AND [Level] = @original_Level"  
        
        UpdateCommand="UPDATE [HeightWeightLevelTable] SET [HighHeight] = @HighHeight, [HighWeight] = @HighWeight, [Mark] = @Mark, [Level] = @Level WHERE [LowHeight] = @original_LowHeight AND [LowWeight] = @original_LowWeight AND [Sex] = @original_Sex AND [HighHeight] = @original_HighHeight AND [HighWeight] = @original_HighWeight AND [Mark] = @original_Mark AND [Level] = @original_Level" 
        ConflictDetection="CompareAllValues" 
        InsertCommand="INSERT INTO [HeightWeightLevelTable] ([LowHeight], [HighHeight], [LowWeight], [HighWeight], [Sex], [Mark], [Level]) VALUES (@LowHeight, @HighHeight, @LowWeight, @HighWeight, @Sex, @Mark, @Level)" 
        OldValuesParameterFormatString="original_{0}" >
            <DeleteParameters>
                <asp:Parameter Name="original_LowHeight" Type="Double" />
                <asp:Parameter Name="original_LowWeight" Type="Double" />
                <asp:Parameter Name="original_Sex" Type="Boolean" />
                <asp:Parameter Name="original_HighHeight" Type="Double" />
                <asp:Parameter Name="original_HighWeight" Type="Double" />
                <asp:Parameter Name="original_Mark" Type="Int32" />
                <asp:Parameter Name="original_Level" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="HighHeight" Type="Double" />
                <asp:Parameter Name="HighWeight" Type="Double" />
                <asp:Parameter Name="Mark" Type="Int32" />
                <asp:Parameter Name="Level" Type="String" />
                <asp:Parameter Name="original_LowHeight" Type="Double" />
                <asp:Parameter Name="original_LowWeight" Type="Double" />
                <asp:Parameter Name="original_Sex" Type="Boolean" />
                <asp:Parameter Name="original_HighHeight" Type="Double" />
                <asp:Parameter Name="original_HighWeight" Type="Double" />
                <asp:Parameter Name="original_Mark" Type="Int32" />
                <asp:Parameter Name="original_Level" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="LowHeight" Type="Double" />
                <asp:Parameter Name="HighHeight" Type="Double" />
                <asp:Parameter Name="LowWeight" Type="Double" />
                <asp:Parameter Name="HighWeight" Type="Double" />
                <asp:Parameter Name="Sex" Type="Boolean" />
                <asp:Parameter Name="Mark" Type="Int32" />
                <asp:Parameter Name="Level" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
        
</div>

    <asp:Label ID="WarnLabel" runat="server" ForeColor="Red" Visible="false" />    
</asp:Content>

